<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/6/2
 * Time: 21:20
 */
namespace app\shop\model;

class TaobaoSkuModel extends BaseModel
{
    protected $table="xst_taobao_sku";
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];
    //规格显示
    public function index()
    {
        return $this->field('ts.id,tt.name')->alias('ts')->join('xst_taobao_type tt','ts.type_id=tt.id')->paginate(10,false,['query'=>request()->param()]);
    }
    //规格添加
    public function add()
    {
        $name = request()->post('name');
        return $this->insert([
            'name'=>$name
        ]);
    }
    //规格修改
    public function edit()
    {
        $name = request()->post('name');
        $id = request()->post('id');
        return $this->where('id',$id)->update([
            'name'=>$name
        ]);
    }
    //规格修改前的查询
    public function getOneId($id)
    {
        return $this->where('id',$id)->find();
    }
    //规格删除
    public function del()
    {
        $id=request()->post('id');
        return $this->where('id',$id)->delete();
    }
}